﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;

public partial class Manager_Menu_AddMenu : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["AdminUserID"] == null)
        {
            Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
            return;
        }
        if (!IsPostBack)
        {
            BindLevel();
        }
    }

    private void BindLevel()
    {
        clsWebShop cls = new clsWebShop();
        ddlLevel.DataSource = cls.Get_GroupMenuOderMenuNameNoneProc().Tables[0];
        ddlLevel.DataTextField = "MenuName";
        ddlLevel.DataValueField = "MenuID";
        ddlLevel.DataBind();
        ListItem item = new ListItem();
        item.Text = "--Nhóm menu--";
        item.Value = "0";
        ddlLevel.Items.Insert(0, item);

        ddlKindNo.Items.FindByValue(Request.QueryString["sKindNo"]).Selected = true;
    }
    private void ReturnPage()
    {
        Response.Redirect("Menu.aspx?sKindNo=" + ddlKindNo.SelectedValue + "&CodeID=" + Request.QueryString["CodeID"]);
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("MenuName",txtMenu.Text);
        msg.CreateFirstNode("MenuURL",txtURL.Text);
        msg.CreateFirstNode("LevelMenuID",ddlLevel.SelectedValue);
        msg.CreateFirstNode("KindNo",ddlKindNo.SelectedValue);
        msg.CreateFirstNode("UpdID","0");

        clsWebShop cls = new clsWebShop();
        cls.Ins_Menu(msg.GetXmlStr.ToString());
        ReturnPage();
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        ReturnPage();
    }
}
